# 字符串编码，解码,编码错误
"本周第二节".encode("utf-8")
b'\xe6\x9c\xac\xe5\x91\xa8\xe7\xac\xac\xe4\xba\x8c\xe8\x8a\x82'

b'\xe6\x9c\xac\xe5\x91\xa8\xe7\xac\xac\xe4\xba\x8c\xe8\x8a\x82'
b. decode("utf")



chardet.detect(b)
b_2 = "本周". encode("utf-8") + "第二节". encode("gbk")
chardet. detect(b)
b_2. encode("utf-8", errors = 'ignore')
b_2. encode("utf-8", errors = 'replace')

#字符串CRUD操作
 #create
 a = 1
 b = 2
 a += b
 #retrieve
a = "hello, world"
a[2] = 'l'
a.find("o")
4
a.index("l")
2
a = "2020-12-24-xxxx"
a.startswith("2020-12-24")
a.endswith("xxxx")
#update
a = "helle, world"
a. replace("le", "lo")


a = "python, java, C"
a.split(", ")

b = a.split(", ")
", ". join(b)

#Delete
a = "      python   "
a.strip()
a.rstrip()
a.lstrip()


#字符串的格式化
a = "here"
b = "there"
print("I {} {}".format(a, b))

a = "here"
b = "there"
print("I {0} {1}".format(a, b))

a = "here"
b = "there"
print("I {a} {b}".format(a = "here", b = "there"))

a = "here"
b = "there"
print(f"I {a} {b}")

print("{: .3f}". format(1.23456))

